package cl.mt.mvc.action;

import java.util.Collection;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import cl.mt.dto.DTOUsuario;
import cl.mt.mvc.helper.oferente.DatosUsuarioHelper;

public class AdminUserEmpresaAction extends Action {

	private Logger log = LogManager.getLogger(LoginAction.class.getName());
	
	  public ActionForward execute (ActionMapping mapping, ActionForm form,
			  	HttpServletRequest request, HttpServletResponse response) {
		  String forward 	="";
		  String accion 	= request.getParameter("accion")==null ? request.getParameter("accion") : "listUser" ;
		  DTOUsuario userLogin = (DTOUsuario) request.getSession().getAttribute("userLogin");
		  
		  DatosUsuarioHelper help = new DatosUsuarioHelper();
		  
		  if("listUser".equals(accion)){
			 
			  Collection<DTOUsuario>  col = help.listarUserEmp(userLogin);
			  log.debug("cantidad de userEmpresas:"+col.size());
			  
			  request.setAttribute("listUsuarios", col);
			  
			  forward ="LISTAR";
			  
		  }else if("verDetalle".equals(accion)){
			
			  
			  
		  }else if("modificar".equals(accion)){
			  
			  
		
		  }else if("eliminar".equals(accion)){
			  
			  
			  
			  
		  }else if("agregar".equals(accion)){
			  
		  }else{
			  
		  }
				
		  
		  
		  
		  return mapping.findForward(forward);
	  }

}
